<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
      <link rel="stylesheet" href="${pageContext.request.contextPath}/cts/css/style.css" type="text/css"/>
	  <script type="text/javascript" src="${pageContext.request.contextPath}/cts/js/jquery.js"></script>
	  <script type="text/javascript" src="${pageContext.request.contextPath}/cts/js/popdiv.js"></script>
	  <script type="text/javascript" src="${pageContext.request.contextPath}/cts/js/jquery.bgiframe.js"></script>
	  
	   <script type="text/javascript">
	   
	       $(function(){
	          var width = $(document).width();
	          var height = $(document).height();
	          var csHeight = $("#centerSpace").height();
	          
	          height = (height / 2) - (csHeight + (csHeight / 2));
	          $("#centerSpace").css({
	             "margin-top":200
	          });
	          
	       });
	       
	       function saveInfo(){
	          var type = '<s:property value="#request.iscreate"/>';
	          var inviteCode = $("#inviteCode").val();
	          var errorMsg = "";
	          if(type == 'true'){
	             var pwd = $("#pwd").val();
	             var enterpwed = $("#enterpwed").val();
	             
	             if(pwd == ''){
	               errorMsg += "密码,";
	             }
	             
	             if(enterpwed == ''){
	               errorMsg += "确认密码";
	             }
	             
	             
	             if(errorMsg != ''){
	               errorMsg = errorMsg.replace(/,$/ , '');
	               alert(errorMsg+"不能为空");
	               return;
	             }
	             
	             if(pwd!='' && enterpwed!='' && pwd.length < 6){
	               alert("密码长度要大于6位");
	               return;
	             }
	             
	             if(pwd!=enterpwed){
	               alert("密码不一致");
	               return;
	             }
	          }
	          
	          if(inviteCode == ''){
	             alert("邀请码不能为空");
	             return;
	          }
	          
	          var param = $("#codeForm").serialize();
	          $.post("cts/angainAdd.action" , param , function(data){
	              if(data == -1){
	                 alert("邀请码已无效");
	              }else if(data == 1){
	                 if(confirm("邀请成功\n是否登录此用户")){
	                   window.location.href = "${pageContext.request.contextPath}/cts/index?usetype=1&userId=<s:property value="#request.userId"/>"
	                 }else{
	                   window.close();
	                 }
	                 //alert("邀请成功");
	              }else{
	                 alert("邀请失败");
	              }
	          });
	          
	       }
	   </script>
	   
	   <STYLE type="text/css">
	      #centerSpace table tr td{
	         height:30px;
	         line-height: 30px;
	      }
	   </STYLE>
  </head>
  
  <body>
  
    <form id="codeForm" >
	    <div align="center">
	     <div id="centerSpace" style="width:300px;height:auto;background-color: #ececec;border:1px solid gray;text-align: center;" align="center">
	        <input type="hidden" id="userId" name="userId" value="<s:property value="#request.userId"/>"/>
	        <input type="hidden" id="employeeId" name="employeeId" value="<s:property value="#request.employeeId"/>"/>
	        
	        <table cellpadding="0" cellspacing="0" style="margin:20px 0px 20px 0px;font-size:12px;width:100%">
	           <tr>
	              <td align="right" width="90px">用户名：</td>
	              <td>
	                 <s:property value="#request.userName"/>
	                 <input type="hidden" id="username" name="username" value="<s:property value="#request.userName"/>"/>
	              </td>
	           </tr>
	           <s:if test="#request.userStatus == 2 ">
		           <tr>
		              <td  align="right">密码：</td>
		              <td>
		                 <input type="password" id="pwd" name="pwd" value="" style="width:155px;"/>
		              </td>
		           </tr>
		           <tr>
		              <td  align="right">确认密码：</td>
		              <td>
		                 <input type="password" id="enterpwed" value="" style="width:155px;"/>
		              </td>
		           </tr>
	           </s:if>
	           <tr>
	              <td  align="right">邀请码：</td>
	              <td>
	                <input type="text" id="inviteCode" name="inviteCode" value="" style="width:155px;"/>
	              </td>
	           </tr>
	           <tr>
	              <td colspan="2" align="center">
	                <input onclick="saveInfo()" type="button" id="inviteCode"  style="border:1px solid gray;padding:2px 4px 2px 4px;margin-top:20px;" value="确定"/>
	              </td>
	           </tr>
	        </table>
	     </div>
	    </div>
    </form>
    
    <div id="msgShowmsg"></div>
  </body>
</html>
